package com.qian.ddj.web.controller;

import com.qian.api.ddj.model.DaifuLog;
import com.qian.api.ddj.service.IDaifuService;
import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import com.yaowk.web.system.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ddj/daifu")
public class DaifuController {

    @Autowired
    private IDaifuService daifuService;

    @PostMapping
    public DaifuLog save(DaifuLog daifuLog) {
        daifuLog.setUserId(SecurityUtils.getUserId());
        daifuLog = daifuService.send(daifuLog);
        return daifuLog;
    }

    @GetMapping
    public PageResp<DaifuLog> list(PageReq pageReq) {
        DaifuLog daifuLog = new DaifuLog();
        daifuLog.setUserId(SecurityUtils.getUserId());
        PageResp<DaifuLog> page = daifuService.findAll(daifuLog, pageReq);
        return page;
    }

}
